<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta content="telephone=no" name="format-detection" />
    <!-- 留作将来统一添加 -->
    <TEMPLATE>${TEMPLATE}</TEMPLATE>
    <title>模板html</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <link rel="stylesheet" type="text/css" href="../../css/data-flex.min.css">
    <style type="text/css">
        body {
            background: #F5F5F5;
        }

        .item-container {
            height: 130px;
            margin: 15px;
            background-image: url("../../image/ui/item_bg.png");
            background-size: 100% 100%;
            padding: 0 30px;
        }

        .item-container .title {
            color: #FFFFFF;
            font-size: 22px;
            font-weight: 500;
        }

        .item-container .icon {
            width: 55px;
            height: 56px;
        }
    </style>
</head>
<body>
    <div class="vueApp" v-cloak>
        <div class="item-container" v-for="item,index in listData" @click="openAnswerDetail(index)" data-flex="cross:center main:justify">
            <div class="title">{{item.catalogName}}</div>
            <img :src="item.catalogIcon" alt="" class="icon">
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-logic.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript">
    // html 的引号一律为双引号(""),js 为单引号('')
    var USER, $S, vm, pageParam;
    apiready = function() {
        $S = SERVICE();
        USER = USER();
        console.log(JSON.stringify(api.pageParam) + '=====pageParam');
        pageParam = api.pageParam;
        fnInit();
        api.addEventListener({
            name: 'answerComplete'
        }, function() {
            getData();
        });
    };

    // 初始化
    function fnInit() {
        vm = new Vue({
            el: '.vueApp',
            data: {
                listData: []
            }
        });
        getData();
    }

    // 获取数据
    function getData() {
        var url = 'stuPicture/findPictureBookCatalogList';
        var params = {
            id: pageParam.itemId
        };
        var callback = function(data) {
            vm.listData = data.listData;
        };
        POST(url, params, callback);
    }

    // 进入练习题详情
    function openAnswerDetail(index) {
        var item = vm.listData[index];
        if(item.scoreValue !== '') {
            fnOpenWin({
                name: 'answer_end',
                url: './answer_end.html',
                pageParam: {
                    score: item.scoreValue,
                    time: Number(item.totalDuration),
                    typeCode: item.catalogQuestionTypeCode,
                    catalogId: item.id,
                    catalogName: item.catalogName
                }
            });
        } else {
            fnOpenPublicWin(item.catalogName, 'video/answer_detail', {
                isBtn: true,
                btnName: '00:00',
                typeCode: item.catalogQuestionTypeCode,
                catalogId: item.id,
                catalogName: item.catalogName
            });
        }
    }

    // 点击错题集
    function headerFn() {
        fnOpenPublicWin('错题集', 'video/error_list', {
            itemId: pageParam.itemId
        });
    }


</script>
</html>
